package com.cmsky.open.security.manager;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.*;

import com.cmsky.open.core.base.*;
import com.cmsky.open.core.util.*;

import cn.org.rapid_framework.util.*;
import cn.org.rapid_framework.web.util.*;
import cn.org.rapid_framework.page.*;
import cn.org.rapid_framework.page.impl.*;

import com.cmsky.open.security.model.*;
import com.cmsky.open.security.dao.*;
import com.cmsky.open.security.manager.*;
import com.cmsky.open.security.vo.query.*;

/**
 * @author jandyfish email:jandyfish(a)gmail.com
 * @version 1.0
 * @since 1.0
 */


@Service
@Transactional
public class RoleActionsInfoManager extends BaseManager<RoleActionsInfo,java.lang.Integer>{

	private RoleActionsInfoDao roleActionsInfoDao;
	/**增加setXXXX()方法,spring就可以通过autowire自动设置对象属性,请注意大小写*/
	public void setRoleActionsInfoDao(RoleActionsInfoDao dao) {
		this.roleActionsInfoDao = dao;
	}
	public EntityDao getEntityDao() {
		return this.roleActionsInfoDao;
	}
	
	public int saveOrUpdate(RoleActionsInfo entity) {
		if(entity.getId() == null 
				|| entity.getId() <= 0) 
			return save(entity);
		else 
			return update(entity);
	}
	
	@Transactional(readOnly=true)
	public BasePager findPage(RoleActionsInfoQuery query) {
		return roleActionsInfoDao.findPage(query);
	}
	
	public int deleteByKey(RoleActionsInfoQuery query){
		return this.roleActionsInfoDao.deleteByKey(query);
	}
	
	public int grant(List<RoleActionsInfo> list,RoleActionsInfoQuery query) {
		int result = 0;
		this.deleteByKey(query);
		for(RoleActionsInfo info : list){
			result += this.save(info);
		}
		return result;
	}
	
}
